package com.example.alarm;

import android.annotation.SuppressLint;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import java.io.File;

public class MySQLiteOpenHelper extends SQLiteOpenHelper {

    public SQLiteDatabase sqlitedb;
    @SuppressLint("SdCardPath")
    public static String dbPath = "/sdcard/my.db";

    public SQLiteDatabase init() {
        Log.i("SD卡路径", SdCardUtil.getSdPath());
        File file = new File(dbPath);
        if (file.exists()) {
            Log.i("MySQLiteOpenHelper", "数据库已存在");
        }
        //调用此方法时，判断数据库是否存在，不存在则创建 调用OnCreate方法，存在则不调，直接放回数据库对象
        sqlitedb = this.getWritableDatabase();
        return sqlitedb;
    }

    public MySQLiteOpenHelper(Context context) {
        super(context, dbPath, null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {

    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }
}